<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
</head>
<body class="gray-bg">
     <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="${path}/organ/setadmin" class="form-horizontal m-t" id="menuForm" method="post">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">当前管理号码：</label>
                                <div class="col-sm-8">
                                    <input type="hidden" name='id' value='${id}'/>
                                    <c:if test="${user==null}">
                                    <input type="text" disabled class="form-control" value='未设置'/>
                                    </c:if>
                                    <c:if test="${user!=null}">
                                        <input type="text" disabled class="form-control" value='${user.mobile}'/>
                                    </c:if>

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">当前管理昵称：</label>
                                <div class="col-sm-8">
                                    <c:if test="${user==null}">
                                        <input type="text" disabled class="form-control" value='未设置'/>
                                    </c:if>
                                    <c:if test="${user!=null}">
                                        <input type="text" disabled class="form-control" value='${user.name}'/>
                                    </c:if>

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">新管理员：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="" id="name" name="moblie" class="form-control" placeholder="输入用户的手机号绑定为机构管理员" required="">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3" style="text-align: center;">
                                    <button class="btn btn-primary" id="update-btn" type="button">确认</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/common/hplus-js.jsp"%>
    <script src="${path}/assets/hplus/js/demo/form-validate-demo.js"></script>
    <script>
        $(document).ready(function () {
            $("#menuForm").validate();
            $("#update-btn").click(function(){
                var valid = $("#menuForm").valid();
                if(valid){
                    $("#menuForm").ajaxSubmit({
                        dataType: "json",
                        success: function (json) {
                            var code = json.code;
                            if(code == 0){
                                layer.msg('绑定成功', {icon: 1});
                                setTimeout(function(){
                                    window.parent.location.reload();
                                    parent.layer.closeAll();
                                }, 1000);
                            }else{
                                layer.msg(json.msg, {icon: 5});
                            }
                        },
                        error:function(){
                            layer.msg('修改发生错误', {icon: 5});
                        }
                    });
                }else{
                	layer.msg("请填写完整信息！！！！", {
        				icon : 5
        			});
                }
            });
        });
    </script>
</body>
</html>
